#include <stdio.h>
#include <stdlib.h>


typedef struct linknode
{
	int data;
	struct linknode *next;
}link_node;

link_node *creat()
{
	link_node *H=(link_node *)malloc(sizeof(link_node ));
	H->data=0;
	H->next==NULL;

	return H;
}

int insert(link_node *H,int newdata)
{
	link_node *p=H;
	while(p->next!=NULL)
	{
		p=p->next;
	}
	link_node *q=(link_node *)malloc(sizeof(link_node ));
	q->data=newdata;
	q->next=NULL;
	p->next=q;

	return 0;
}

int view(link_node *H)
{
	link_node *p=H;
	while(p->next!=	NULL)
	{
		p=p->next;
		printf("%d ",p->data);
	}
	putchar(10);
	return 0;
}

int deletenode(link_node *H)
{
	link_node *p=H;
	link_node *q=NULL;
	while(p->next!=NULL)
	{
		p=p->next;
		if(p->data!=p->next->data)
		{
			p=p->next;
		}
		else
		{
			q=p->next;
			p->next=q->next;
			free(q);
		}
	}
}

int main(int argc, const char *argv[])
{
	link_node *H=creat();
	insert(H,1);
	insert(H,1);
	insert(H,2);
	insert(H,2);
	insert(H,3);
	insert(H,3);
	view(H);

	deletenode(H);
	view(H);

	return 0;
}
